package hn.sigit.logic.viewer.toolbox;

//import hn.sigit.logic.bpm.ParcelData;
import hn.sigit.logic.ladmshadow.Util;
import hn.sigit.logic.workflow.transaction.DataEntryHelper;
import hn.sigit.model.hnd.administrative.HND_SpatialZoneInTransaction;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class UndoHelper implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private DataEntryHelper dataEntryHelper;
	
	public UndoHelper(DataEntryHelper dataEntryHelper) {
		this.dataEntryHelper = dataEntryHelper;
	}
	
	public String applyUndo() {
		//TODO: Yet to finish
		Util.undoLastOperation(dataEntryHelper.getPresentationId());
		return null;
	}
	
	public String applyUndoAll() {
		//List<ParcelData> parcelDataList = dataEntryHelper.getTransactionHelper().getParcelDataList();
		List<Long> parcelIdList = new ArrayList<Long>();
		for (HND_SpatialZoneInTransaction szit : dataEntryHelper.getTransactionHelper()
				.getTransaction().getSpatialZoneInTransactions())
			parcelIdList.add(szit.getSpatialZoneId());
		//for (ParcelData pd : parcelDataList)
		//	parcelIdList.add(Long.valueOf(pd.getSuID()));
		
		Util.undoAll(dataEntryHelper.getPresentationId(), parcelIdList);
		return null;
	}

}
